import request from '@/utils/request'

// 系统设置API
export const settingApi = {
  // 根据ID查询系统设置
  queryById(id) {
    return request({
      url: `/admin/setting/${id}`,
      method: 'GET'
    })
  },

  // 根据Key查询系统设置
  queryByKey(settingKey) {
    return request({
      url: `/admin/setting/key/${settingKey}`,
      method: 'GET'
    })
  },

  // 分页查询系统设置
  queryPage(pageNum, pageSize, params = {}) {
    return request({
      url: '/admin/setting/page',
      method: 'POST',
      params: {
        pageNum,
        pageSize
      },
      data: params
    })
  },

  // 根据条件查询系统设置列表
  queryList(params) {
    return request({
      url: '/admin/setting/list',
      method: 'POST',
      data: params
    })
  },

  // 创建系统设置
  create(data) {
    return request({
      url: '/admin/setting',
      method: 'POST',
      data
    })
  },

  // 更新系统设置
  update(id, data) {
    return request({
      url: `/admin/setting/${id}`,
      method: 'PUT',
      data
    })
  },

  // 删除系统设置
  delete(id) {
    return request({
      url: `/admin/setting/${id}`,
      method: 'DELETE'
    })
  },

  // 批量删除系统设置
  deleteBatch(ids) {
    return request({
      url: '/admin/setting/batch',
      method: 'DELETE',
      data: ids
    })
  },

  // 根据分组查询系统设置
  queryByGroup(groupName) {
    return request({
      url: `/admin/setting/group/${groupName}`,
      method: 'GET'
    })
  }
}
